package com.guigu.dh.controller;

import com.guigu.dh.common.result.Result;
import com.guigu.dh.service.DepartmentService;
import com.guigu.dh.service.HospitalService;
import com.guigu.dh.service.ScheduleService;
import com.guigu.dh.vo.hosp.HospitalQueryVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@Api(tags = "医院相关操作")
@RestController
@RequestMapping("admin/hosp/hospital")
public class HospitalController {

    @Autowired
    private HospitalService hospitalService;
    @Autowired
    private DepartmentService departmentService;
    @Autowired
    private ScheduleService scheduleService;

    @ApiOperation("查询医院信息列表")
    @PostMapping("/list/{currentPage}/{limit}")
    public Result showHospitalPage(@PathVariable Integer currentPage,
                                   @PathVariable Integer limit,
                                   @RequestBody HospitalQueryVO hospitalQueryVO){
        Result result = hospitalService.selectPage(currentPage,limit,hospitalQueryVO);

        return result;
    }

    @ApiOperation("查询医院详情")
    @GetMapping("/showDetails/{id}")
    public Result showDetails (@PathVariable String id){
        return hospitalService.showDetails(id);
    }

    @ApiOperation("修改医院状态")
    @PutMapping("/lockHospital/{id}/{status}")
    public Result lockHospital(@PathVariable String id,
                               @PathVariable String status){
        return hospitalService.lockHospital(id,status);
    }

    @ApiOperation("根据医院编号查科室")
    @GetMapping("/queryDepartmentByHoscode/{hoscode}")
    public Result queryDepartmentByHoscode (@PathVariable String hoscode) {
        return departmentService.queryDepartmentByHoscode(hoscode);
    }

    @ApiOperation("根据医院编号和科室编号查医生日程安排")
    @GetMapping("/findSchedulePage/{currentPage}/{limit}/{hoscode}/{depcode}")
    public Map<String, Object> findSchedulePage (@PathVariable Integer currentPage,
                                                 @PathVariable Integer limit,
                                                 @PathVariable String hoscode,
                                                 @PathVariable String depcode){
        return scheduleService.findSchedulePage(currentPage,limit,hoscode,depcode);
    }

    @ApiOperation("根据日期查排班")
    @GetMapping("/showScheduleByWorkDate/{hoscode}/{depcode}/{workDate}")
    public Result showScheduleByWorkDate (@PathVariable String hoscode,
                                          @PathVariable String depcode,
                                          @PathVariable String workDate) {
        return scheduleService.showScheduleByWorkDate(hoscode,depcode,workDate);
    }

}
